package com.lazyfish.factorybean;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

public class MyAspect implements MethodInterceptor {
    @Override
    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        check_Permissions(methodInvocation);
        Object object = methodInvocation.proceed();
        log();
        return object;
    }
    public void check_Permissions(MethodInvocation methodInvocation) throws Exception{
        System.out.println(methodInvocation.getMethod().getName());
        if(methodInvocation.getMethod().getName().equals("love")){
            throw new Exception("不允许的操作");
        }
        System.out.println("权限检查中");
        
    }
    public void log(){
        System.out.println("写出日志");
    }
}
